﻿@model FCNS.ERP.Models.ErpVip

@{
    ViewBag.Title = "会员类型-编辑";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>@ViewBag.Title</h2>

<script type="text/javascript">
    $(document).ready(function () {
        $("#countAll").change(function () {
            if ($("#countAll").prop("checked") == true) {
                $("#InitValue").val(0);
            }
            else {
                $("#InitValue").attr("readonly", false);
                $("#InitValue").val(1);
            }
        });

        $("#VipFlag").change(function () {
            if ($("#VipFlag").val() == 1) {
                $("#countAll").attr("disabled", "disabled");
                $("#countAll").prop("checked", false);
                $("#Discoun").attr("readonly", false);
                $("#BonusPerYuan").attr("readonly", false);
                $("#InitValue").parent().prev().text("初始化积分");

            }
            else {
                $("#countAll").removeAttr("disabled");
                $("#Discoun").attr("readonly", true);
                $("#BonusPerYuan").attr("readonly", true);
                $("#InitValue").parent().prev().text("次数");

            }
        });

        $("#VipFlag").change();

        if ($("#InitValue").val() == 0 && $("#VipFlag").val() == 0) {
            $("#countAll").prop("checked", true);
            $("#InitValue").attr("readonly", true);
        }

        $("#VipId").change(function () {
            $.get("/Vip/GetVip", {
                id: $(this).val()
            }, function (data, status) {
                if (status == "success") {
                    if (data != null) {
                        $("#Balance").val(data["InitValue"]);
                    }
                }
            });
        });

    });
</script>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.Id)


        <div class="form-group">
            @Html.LabelFor(model => model.Enable, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.CheckBoxFor(model => model.Enable, htmlAttributes: new { @checked = "checked" })
                    @Html.ValidationMessageFor(model => model.Enable, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.VipFlag, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EnumDropDownListFor(model => model.VipFlag, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.VipFlag, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Month, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Month, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Month, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Money, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Money, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Money, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.InitValue, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.InitValue, new { htmlAttributes = new { @class = "form-control" } })
                <input type="checkbox" id="countAll" />&nbsp;不限
                @Html.ValidationMessageFor(model => model.InitValue, "", new { @class = "text-danger" })
            </div>
        </div>


        <div class="form-group">
            @Html.LabelFor(model => model.Discoun, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Discoun, new { htmlAttributes = new { @class = "form-control", @Max = "1", @type = "number", @Min = "0.01", @Step = "0.01" } })
                @Html.ValidationMessageFor(model => model.Discoun, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.BonusPerYuan, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.BonusPerYuan, new { htmlAttributes = new { @class = "form-control", @type = "number", @Min = "0.01", @Step = "0.01" } })
                @Html.ValidationMessageFor(model => model.BonusPerYuan, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="保存" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    <a class="backToListImg" href="/Vip/Vip">返回</a>
</div>
